<template>
    <div style="margin:20px;padding:20px;background-color:#fff;">
        <el-button type="primary" size="small" @click="goAdd" style="margin-bottom:10px;">添加管理员</el-button>
        <el-form :inline="true" class="demo-form-inline" size="small">
            <el-form-item label="管理员姓名">
                <el-input v-model="s_user_name" placeholder="请输入" clearable></el-input>
            </el-form-item>
            <el-form-item label="手机号">
                <el-input v-model="s_phone" maxlength="11" placeholder="请输入" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableInfo" size="small">
            <el-table-column prop="index" label="序号"></el-table-column>
            <el-table-column prop="name" label="姓名"></el-table-column>
            <el-table-column prop="phone" label="手机号"></el-table-column>
            <el-table-column prop="company" label="公司"></el-table-column>
            <el-table-column prop="department" label="部门"></el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="goWrite" size="small">修改</el-button>
                    <el-button type="text" @click="goDelete" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
    
</template>

<script>
    export default {
        data() {
            return {
                s_user_name:'',
                s_phone:'',
                tableInfo:[
                ]
            }
        },
        mounted(){
            this.$emit('nowRoute','管理员列表')
            this.getData()
        },
        methods: {
            getData(){
                this.$axios({
                    url: this.$url.admin,
                    method:'get',
                }).then(response=>{
                    if(response.data.result.success){
                        let option = []
                        let index = 0
                        for(let value of response.data.content.data){
                            index ++
                            option.push({
                                index:index,
                                name:value.username,
                                phone:value.phone,
                                company:value.company_name,
                                department:value.department,
                                id:value.id
                            })
                        }
                        this.tableInfo = option
                    }
                }).catch(error=>{
                    console.log(error);
                })
            },
            onSubmit() {
                console.log('submit!');
            },
            goWrite(){
                this.$router.push("/admin-list/edit")
            },
            goDelete(){

            },
            goAdd(){
                this.$router.push("/admin-list/add")
            }
        },
    }
</script>

<style scoped>

</style>